package crypt_kicker_II;

import java.util.*;
import java.io.*;
/*
 * Problem ID: 110304 
 * Algorithm: 
 * If we can assume that the sentence: "the quick brown fox jumps over the lazy dog" 
 * will be part of the solution, then we can easily traverse through 
 * the input and and find the proper mapping. After the rest of the problem becomes trivial.
 */
class CryptKickerII 
{
	public static void main(String [] args)
	{
		new CryptKickerII().start();
	}
	
	public void start()
	{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		
		try
		{
			int numOfCases = Integer.parseInt(reader.readLine());
			
			String init = "the quick brown fox jumps over the lazy dog";
			
			HashMap<String, String> initMapping;
			
			boolean isFound = false;
			
			// reader blank line.
			reader.readLine();
			
			ArrayList<String> encryptionList;
			
			for (int i = 0; i < numOfCases; i++)
			{
				if (i != 0)
				{
					reader.readLine();
				}
				
				String encryption = "";
				encryptionList = new ArrayList<String>();
				isFound = false;
				
				while (!(encryption = reader.readLine()).equals(""))
				{
					encryptionList.add(encryption);
				}
				
				for (int j = 0; j < encryptionList.size(); j++)
				{
					encryption = encryptionList.get(j);
					
					if (matches(init, encryption))
					{
						initMapping = createInitMapping(encryption);
						if (verifyMapping(init, encryption, initMapping));
						{
							isFound = true;
							cryptKickMe(encryptionList, initMapping);
							break;
						}
					}
				}
				
				if (isFound == false)
				{
					System.out.println("No Solution.");
				}
			}
		} 
		catch (IOException ex)
		{
			ex.printStackTrace();
		}
	}
	
	public void cryptKickMe(ArrayList<String> encryptionList, HashMap<String, String> initMapping)
	{
		String result = "";
		
		for (int i = 0; i < encryptionList.size(); i++)
		{
			String encrypt = encryptionList.get(i);
			
			for (int j = 0; j < encrypt.length(); j++)
			{
				String encryptWordLetter = encrypt.charAt(j) + "";
				
				if (encryptWordLetter.equals(" "))
				{
					result += " ";
				}
				else
				{
					String value = initMapping.get(encryptWordLetter);
					
					result += value;
				}
			}
			
			System.out.println(result.trim());
			result = "";
		}
	}
	
	public HashMap<String, String> createInitMapping(String word)
	{
		HashMap<String, String> temp = new HashMap<String, String>();
		
		for (int i = 0; i < word.length(); i++)
		{
			String letter = word.charAt(i) + "";
			
			if (!letter.equals(" "))
			temp.put(letter, "");
		}
		
		return temp;
	}
	
	public boolean matches(String init, String encryption)
	{
		boolean done = false;
		boolean matches = false;
	
		while (done == false)
		{
			int initBlankLoc = init.indexOf(" ");
			int encryptBlankLoc = encryption.indexOf(" ");
			
			if (initBlankLoc == -1 && encryptBlankLoc == -1)
			{
				if (init.length() == encryption.length())
				{
					matches = true;
				}
				break;
			}
			else if (initBlankLoc != encryptBlankLoc)
			{
				break;
			}
					
			init = init.substring(initBlankLoc).trim();
			encryption = encryption.substring(encryptBlankLoc).trim();
		}
		
		return matches;
	}
	
	public boolean verifyMapping(String initWord, String encryptWord, HashMap<String, String> temp)
	{
		for (int i = 0; i < encryptWord.length(); i++)
		{
			String initLetter = initWord.charAt(i) + "";
			String encryptLetter = encryptWord.charAt(i) + "";
			
			if (!encryptLetter.equals(" "))
			{
				String initValue = temp.get(encryptLetter);
				
				if (initValue.equals(""))
				{
					temp.put(encryptLetter, initLetter);
				}
				else if (!initValue.equals(initLetter))
				{
					temp.clear();
					return false;
				}
			}
		}
		return true;
	}
}
